import 'package:flutter_admin/utils/utils.dart';

class ProductUsermeritpay {
  String? id;
  String? factoryId;
  String? factoryName;
  String? workshopId;
  String? workshopName;
  String? stationId;
  String? stationName;
  String? productdate;
  String? userId;
  String? userName;
  String? reportyield;
  String? meritpay;
  String? createUid;
  String? createName;
  String? createDate;
  String? writeUid;
  String? writeDate;
  String? post;

  ProductUsermeritpay({
    this.id,
    this.factoryId,
    this.factoryName,
    this.workshopId,
    this.workshopName,
    this.stationId,
    this.stationName,
    this.productdate,
    this.userId,
    this.userName,
    this.reportyield,
    this.meritpay,
    this.createUid,
    this.createName,
    this.createDate,
    this.writeUid,
    this.writeDate,
    this.post,
  });

  ProductUsermeritpay copyWith({
    String? id,
    String? stationId,
    String? productdate,
    String? user,
    String? reportyield,
    String? meritpay,
    String? createUid,
    String? createDate,
    String? writeUid,
    String? writeDate,
  }) {
    return new ProductUsermeritpay(
      id: id ?? this.id,
      stationId: stationId ?? this.stationId,
      productdate: productdate ?? this.productdate,
      userId: user ?? this.userId,
      reportyield: reportyield ?? this.reportyield,
      meritpay: meritpay ?? this.meritpay,
      createUid: createUid ?? this.createUid,
      createDate: createDate ?? this.createDate,
      writeUid: writeUid ?? this.writeUid,
      writeDate: writeDate ?? this.writeDate,
    );
  }

  @override
  String toString() {
    return '''ProductUsermeritpay{
      id: id,
      stationId: stationId,
      productdate: productdate,
      user: user,
      reportyield: reportyield,
      meritpay: meritpay,
      createUid: createUid,
      createDate: createDate,
      writeUid: writeUid,
      writeDate: writeDate,
    }''';
  }

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      (other is ProductUsermeritpay &&
          runtimeType == other.runtimeType &&
          id == other.id &&
          stationId == other.stationId &&
          productdate == other.productdate &&
          userId == other.userId &&
          reportyield == other.reportyield &&
          meritpay == other.meritpay &&
          createUid == other.createUid &&
          createDate == other.createDate &&
          writeUid == other.writeUid &&
          writeDate == other.writeDate);

  factory ProductUsermeritpay.fromMap(Map<String, dynamic> map) {
    return new ProductUsermeritpay(
      id: map['id'] != false ? map['id'].toString() as String? : "",
      post:
          map['job_id'] != false ? map['job_id'][1].toString() as String? : "",
      factoryId: map['factory_id'] != false
          ? map['factory_id'][0].toString() as String?
          : "",
      factoryName: map['factory_id'] != false
          ? map['factory_id'][1].toString() as String?
          : "",
      workshopId: map['workshop_id'] != false
          ? map['workshop_id'][0].toString() as String?
          : "",
      workshopName: map['workshop_id'] != false
          ? map['workshop_id'][1].toString() as String?
          : "",
      stationId: map['station_id'] != false
          ? map['station_id'][0].toString() as String?
          : "",
      stationName: map['station_id'] != false
          ? map['station_id'][1].toString() as String?
          : "",
      productdate: map['productdate'] != false
          ? Utils.getDate(date: map['productdate'].toString()) as String?
          : "",
      userId: map['user_id'] != false
          ? map['user_id'][0].toString() as String?
          : "",
      userName: map['user_id'] != false
          ? map['user_id'][1].toString() as String?
          : "",
      reportyield: map['postratio'] != false
          ? map['postratio'].toString() as String?
          : "",
      meritpay:
          map['meritpay'] != false ? map['meritpay'].toString() as String? : "",
      createUid: map['create_uid'] != false
          ? map['create_uid'][0].toString() as String?
          : "",
      createName: map['create_uid'] != false
          ? map['create_uid'][1].toString() as String?
          : "",
      createDate: map['create_date'] != false
          ? Utils.timeUTC(map['create_date'].toString()) as String?
          : "",
      writeUid: map['write_uid'] != false
          ? map['write_uid'].toString() as String?
          : "",
      writeDate: map['write_date'] != false
          ? map['write_date'].toString() as String?
          : "",
    );
  }

  Map<String, dynamic> toMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'stationId': this.stationId,
      'stationName': this.stationName,
      'factoryName': this.factoryName,
      'workshopName': this.workshopName,
      'productdate': this.productdate,
      'post': this.post,
      'userId': this.userId,
      'userName': this.userName,
      'reportyield': this.reportyield,
      'meritpay': this.meritpay,
      'createUid': this.createUid,
      'createName': this.createName,
      'createDate': this.createDate,
      'writeUid': this.writeUid,
      'writeDate': this.writeDate,
    } as Map<String, dynamic>;
  }

  List toDomainList() {
    List list = [
      if (this.workshopId != null && this.workshopId != '')
        ['workshop', '=', int.parse(this.workshopId!)],
      if (this.factoryId != null && this.factoryId != '')
        ['factory', '=', int.parse(this.factoryId!)],
      if (this.stationId != null && this.stationId != '')
        ['station_id', '=', int.parse(this.stationId!)],
      if (this.productdate != null && this.productdate != '')
        ['productdate', '=', this.productdate],
      if (this.userName != null && this.userName != '')
        ['name', '=', this.userName],
    ];

    // ignore: unnecessary_cast
    return list;
  }

  Map<String, dynamic> toOdooMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'station_id': this.stationId,
      'productdate': this.productdate,
      'user_id': this.userId,
      'reportyield': this.reportyield,
      'meritpay': this.meritpay,
      'create_uid': this.createUid,
      'create_date': this.createDate,
      'write_uid': this.writeUid,
      'write_date': this.writeDate,
    } as Map<String, dynamic>;
  }

//</editor-fold>

}
